<template>
	<scroll-view scroll-y="true" class="container999" @scroll="scrollTop">
		<navTopIndex title="追剧" :scrollTopNum="scrollTopNum"></navTopIndex>
		<view class="topBox">
			<view class="content-position"></view>
			<view class="bg-box" :style="{
				top: `calc(-${statusBarHeight}px - 94rpx)`
			}"></view>
			<view class="content-box">
				<view class="top-box">
					<view>已连续签到<text class="num-view">{{ continuousSignInDays }}</text>天</view>
					<!-- <view class="right-box">
						签到提醒 <switch class="switch-box" color="#FF6FA2" checked />
					</view> -->
				</view>
				<view class="text-box">签到领看币，新剧抢先看。连续签到7天领惊喜礼包。</view>
				<view class="watch-sign-box">
					<view
						v-for="(item, index) in signListView"
						:key="index"
						class="line-box"
						:class="item.isSignIn ? 'active' : ''"
						@tap="signStatusChange('click')"
					>
						<image v-if="continuousSignInDays > index" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_two.png" ></image>
						<image v-if="continuousSignInDays <= index && item.extraReward" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_three.png" ></image>
						<image v-if="continuousSignInDays <= index && !item.extraReward" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_one.png" ></image>
						<text>{{ item.extraReward ? ((item.extraReward + item.stepReward) / 10).toFixed(0) :  (item.stepReward / 10).toFixed(0) }}</text>
					</view>
				</view>
			</view>
		</view>
		<view v-if="taskConfig && taskConfig.taskTitle && showAd" class="task-popup flex align-center justify-between text-df">
			<view class="flex flex-direction">
				<view class="flex align-center">
					<image class="image-task-box" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_two.png"></image>
					<text class="text-black text-bold text-lg">{{ taskConfig.taskTitle }}</text>
					<text class="text-orange margin-left-xs">+{{ (taskConfig.rewardCoinCount / 10).toFixed(0) }}{{ moneyName }}</text>
				</view>
				<view class="text-gray margin-left-xs margin-top-xs flex align-center">
					<text>{{ taskConfig.taskDesc }}</text>
					<text>（{{ taskConfig.completedNum }}/ {{ taskConfig.dayCounts }}）</text>
				</view>
			</view>

			<view v-if="taskConfig.completedNum < taskConfig.dayCounts" class="right-btn" @click="handleViewAd">立即观看</view>
			<view v-else class="right-btn opacity-set">已完成</view>
		</view>
		<view>
            <view class="block-box">
                <view class="title">
					<text>在追热剧</text>
                    <text v-if="realList.length > 3" class="more-icon" @tap="handleJumpMore('moreHot')">更多></text>
				</view>
                <view class="content-list">
                    <view 
                        class="item-box" 
                        v-for="(item,index) in nowWatchList"
                        @tap="toDetail(item)"
                        :key="index"
                    >
                        <view class="img-box">
                            <image lazy-load :src="item.coverImgUrl"></image>
                        </view>
                        <view class="title-box">{{ item.title }}</view>
                        <view class="text-one">追到第{{ (item.alreadyWatchSequence + 1)  || 1 }}集</view>
                    </view>

					<view class="item-box" v-if="nowWatchList.length < 3 && viewGoView">
                        <view class="img-box-set flex flex-direction align-center justify-center">
                            <image lazy-load src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/no_more_icon.png"></image>
							<text class="text-gray margin-top-xs text-sm">{{ nowWatchList.length > 0 ? '追的剧太少了' : '你还没有追剧哦'}}</text>
							<text class="btn-set" @tap="handleJumpIndex">去追剧</text>
                        </view>
                    </view>
                </view>
            </view>
            <view class="block-box">
                <view class="title">
                    <text>{{ historyTitle || '猜你会追' }}</text>
                    <text v-if="historyList.length > 5" class="more-icon" @tap="handleJumpMore('moreLove')">更多></text>
                </view>
                <view class="content-list style-two">
                    <view 
                        class="item-box"
						:class="((index + 1) % 3) === 0 ? 'no-right' : ''"
                        v-for="(item, index) in historyList" 
                        @tap="toDetail(item)"
                        :key="index"  
                    >
                        <view class="img-box">
                            <image lazy-load :src="item.contentInfo.coverImgUrl"></image>
                        </view>
                        <view class="title-box">{{ item.contentInfo.title }}</view>
                        <view class="text-one">更新至第{{ item.contentInfo.updateOfEpisodes }}集</view>
                    </view>
                </view>
            </view>
           
		</view>
		<!-- 追剧弹窗 -->
		<zwyPopupAll :showClose="true" :maskCanClose="true" ref="zwyPopupAll">
			<view class="content-view flex flex-direction align-center"  v-if="swiperList.length">
				<text class="title-set margin-top-lg text-xl text-bold text-black">{{ recommendObj.name }}</text>
				<text class="mark-box margin-top-xs text-sm text-gray">{{ nowVideoObj.contentInfo.title }}</text>
				<!-- 轮播-begin -->
				<view class="tower-swiper" @touchmove="TowerMove" @touchstart="TowerStart" @touchend="TowerEnd">
					<view
						class="tower-item" 
						:class="item.zIndex == 1 ? 'none' : ''" 
						v-for="(item,index) in swiperList" 
						:key="index" 
						:style="{'--index': item.zIndex,'--left': item.mLeft}" 
						:data-direction="direction"
					>
						<view class="swiper-item">
							<image :src="item.contentInfo.coverImgUrl" lazy-load mode="aspectFill"></image>
						</view>
					</view>
				</view>
				<button class="btn-set" @tap="handleViewVideo">去追剧</button>
			</view>
		</zwyPopupAll>

		<!-- 签到 -->
		<zwyPopupAll :showClose="false" :maskCanClose="false" ref="zwyPopupSign">
			<view class="content-view flex flex-direction align-center">
				<image @tap.stop="handleAddMess" class="close-btn" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/zwyPopupClose.png"></image>
				<text class="margin-top-lg text-xl text-bold text-black">签到成功</text>
				<!-- 开启订阅消息， -->
				<text class="mark-box-set margin-top-sm text-sm text-gray text-center">每天回来看看\n 天天都有免费奖励</text>
				<view class="flex align-center margin-top-xs">
					<image class="img-box-one" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_one.png"></image>
					<text class="text-xl text-black">{{ ((nowItem.stepReward + nowItem.extraReward) / 10).toFixed(0) }} {{ moneyName }}</text>
				</view>
				<image class="img-box-two" @tap="handleAddMess" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/btn_sign.gif" mode="widthFix"></image>
				<!-- <button class="btn-set" @tap="handleJumpIndex">去追剧</button> -->
			</view>
		</zwyPopupAll>

		<!-- 激励任务弹窗  -->
		<zwyPopupAll v-if="taskConfig && taskConfig.rewardCoinCount" :showClose="false" :maskCanClose="false" ref="TaskMessPopup">
			<view class="content-view flex flex-direction align-center">
				<image @tap.stop="handleCloseTaskPopup" class="close-btn" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/zwyPopupClose.png"></image>
				<block v-if="popupType === 1">
					<text class="margin-top-lg text-xl text-bold text-black">恭喜获得</text>
					<!-- 开启订阅消息， -->
					
					<view class="flex align-center margin-top-xs">
						<image class="img-box-one" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_one.png"></image>
						<text class="text-xl text-black">{{ (taskConfig.rewardCoinCount / 10).toFixed(0) }} {{ moneyName }}</text>
					</view>
					<text class="mark-box-set margin-top-sm margin-bottom-sm text-sm text-center">再看{{ taskConfig.dayCounts - taskConfig.completedNum }}个广告获得今日全部奖励</text>
					<button class="btn-set" @tap="handleViewAd">继续看广告</button>
				</block>
				<block v-else-if="popupType === 2">
					<!-- <text class="margin-top-lg text-xl text-bold text-black">获取{{ moneyName }}</text> -->
					<!-- 开启订阅消息， -->
					
					<view class="flex align-center margin-top-xs">
						<image class="img-box-one" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_one.png"></image>
						<text class="text-xl text-black">{{ (taskConfig.rewardCoinCount / 10).toFixed(0) }} {{ moneyName }}</text>
					</view>
					<text class="mark-box-set margin-top-sm margin-bottom-sm text-sm text-center">达到观看时长才可获取奖励哦</text>
					<button class="btn-set" @tap="handleViewAd">继续领{{ moneyName }}</button>
				</block>
				<block v-else-if="popupType === 3">
					<text class="margin-top-lg text-xl text-bold text-black">恭喜获得</text>
					<!-- 开启订阅消息， -->
					
					<view class="flex align-center margin-top-xs">
						<image class="img-box-one" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/ks_sign_one.png"></image>
						<text class="text-xl text-black">{{ (taskConfig.rewardCoinCount / 10).toFixed(0) }} {{ moneyName }}</text>
					</view>
					<text class="mark-box-set margin-top-sm margin-bottom-sm text-sm text-center">今日奖励已全部获取，快去看剧吧</text>
					<button class="btn-set" @tap="handleJumpIndex">去看剧</button>
				</block>
			</view>
		</zwyPopupAll>
		<!-- 激励广告 -->
		<rewardAd 
			v-if="showAd" 
			ref="rewardAd"
			nowAdTypeKs="videoAd"
			@closeAdBox="handleCloseAd"
			@closeAdBoxAndUnlock="closeAdBoxAndUnlock"
		></rewardAd>
	</scroll-view>
</template>

<script>
import rewardAd from '../video/components/rewardAd.vue'

export default {
	components: {
		rewardAd
	},
	data() {
		return {
			taskConfig: null, // 活动配置
			popupType: 1, // 1：完成当前 2： 提前关闭 3：全部完成
			showAd: false, // 加载广告组件
			moneyName: this.moneyName,
			swiperList: [], // 推荐弹窗的列表
			statusBarHeight: uni.getSystemInfoSync()['statusBarHeight'] || 20,
			listLength: 0,
			noMore: 0,
			historyList: [],
			realList: [], // 在追热剧长度
			nowWatchList: [],
			viewGoView: false, // 展示追剧更多
			recommendObj: {},
			pageNum: 1,
			pageSize: 6,
			dotStyle: false,
			towerStart: 0,
			direction: '',
			intervalObj: null,
			nowVideoObj: {},
			signListView: [],
			continuousSignInDays: 0, // 连续签到天数
			scrollTopNum: 0,
			historyTitle: '',
			nowItem: {
				stepReward: 0, 
				extraReward: 0
			} // 当前签到
		};
	},
	beforeDestroy() {
		clearInterval(this.intervalObj)
	},
	methods: {
		reset() {
			this.getNowWatchList()
			this.getIndexConfig()
			this.getSignActiveStatus()
			if(getApp().globalData.isViewOrganization) {
				this.getTaskMess()
			}
			
		},
		handleCloseTaskPopup() {
			this.$refs.TaskMessPopup && this.$refs.TaskMessPopup.close()
		},
		handleCloseAd() {
			this.popupType = 2
			this.$refs.TaskMessPopup && this.$refs.TaskMessPopup.show('mid')
		},
		// 广告观看完毕解锁
		async closeAdBoxAndUnlock() {
			await this.getMoneyView()
			await this.getTaskMess()
			if(this.taskConfig.completedNum < this.taskConfig.dayCounts) {
				this.popupType = 1
			} else {
				this.popupType = 3
			}
			this.$refs.TaskMessPopup && this.$refs.TaskMessPopup.show('mid')
		},
		handleViewAd() {
			console.log('------------------------------吼吼吼吼吼吼吼吼吼吼吼吼吼吼吼');
			this.$statisAd({
				action: 'EXPOSURE',
				adSlot: `SLOT_ID_MOTIVATIONAL_VIDEO_${this.taskConfig.taskId}`
			})
			console.log(this.$refs.rewardAd)
			this.$refs.rewardAd && this.$refs.rewardAd.isShowAd()
		},
		scrollTop(e) {
			this.scrollTopNum = e.detail.scrollTop
		},
		handleJumpIndex() {
			uni.reLaunch({
				url: '/pages/fx_xjc/fx_xjc'
			})
		},
		// 签到
		handleSign() {
			this.addDingMess()
			this.$refs.zwyPopupSign.show('mid')
			this.$uma && this.$uma.trackEvent('Ume_signClick', {
				name: 'Ume_sign_page'
			})
		},
		// 去追剧
		handleViewVideo() {
			let itemObj = this.swiperList.find(item => item.mLeft === 0)
			console.log('itemObj', itemObj)
			itemObj && this.handleJumpDetail(itemObj.contentInfo)
		},
		handleJumpDetail(item) {
			this.direction = ''
			if(!item.fakeId) return
			this.zwyRouter(`../video/video?fakeId=${item.fakeId}&compilationId=${item.compilationId}`);
		},
		// 初始化towerSwiper
		TowerSwiper(name) {
			let list = this[name];
			for (let i = 0; i < list.length; i++) {
				list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
				list[i].mLeft = i - parseInt(list.length / 2)
			}
			this.swiperList = list
			this.nowVideoObj = this.swiperList.find(item => item.mLeft === 0)
		},
		// towerSwiper触摸开始
		TowerStart(e) {
			this.towerStart = e.touches[0].pageX
		},
		// towerSwiper计算方向
		TowerMove(e) {
			this.direction = e.touches[0].pageX - this.towerStart > 0 ? 'right' : 'left'
		},
		// towerSwiper计算滚动
		TowerEnd() {
			let direction = this.direction;
			let list = this.swiperList;
			if (direction == 'right') {
				let mLeft = list[0].mLeft;
				let zIndex = list[0].zIndex;
				for (let i = 1; i < this.swiperList.length; i++) {
					this.swiperList[i - 1].mLeft = this.swiperList[i].mLeft
					this.swiperList[i - 1].zIndex = this.swiperList[i].zIndex
				}
				this.swiperList[list.length - 1].mLeft = mLeft;
				this.swiperList[list.length - 1].zIndex = zIndex;
			} else {
				
				let mLeft = list[list.length - 1].mLeft;
				let zIndex = list[list.length - 1].zIndex;
				for (let i = this.swiperList.length - 1; i > 0; i--) {
					this.swiperList[i].mLeft = this.swiperList[i - 1].mLeft
					this.swiperList[i].zIndex = this.swiperList[i - 1].zIndex
				}
				this.swiperList[0].mLeft = mLeft;
				this.swiperList[0].zIndex = zIndex;
			}
			this.direction = ""
			
			this.nowVideoObj = this.swiperList.find(item => item.mLeft === 0)
			// console.log(this.nowVideoObj)
			this.swiperList = this.swiperList
		},
		// 视频看完获取K币
		async getMoneyView() {
			try {
				await this.zwyRequest({
                    url: `/welfare/task_center/receive/${this.taskConfig.taskId}`,
					method: 'post',
					data: {} 
                })
			} catch (error) {
				console.log(error)
			}
		},
		// 看视频任务获取
		async getTaskMess() {
			try {
				let res = await this.zwyRequest({
                    url: '/welfare/task_center?taskDetailInfo=MOTIVATIONAL_VIDEO_K_COIN'
                })
				let obj = res && res.find(item => item.taskType === 13)
				if(obj) {
					this.showAd = true
					this.taskConfig = obj || {}
				} else {
					this.showAd = false
				}
			} catch (error) {
				console.log(error)
			}
		},
		// 订阅权限弹窗
        async handleAddMess() {
            try {
				let tmplIdsList = []
				let configMess = await this.checkConfigDingYue([
					getApp().globalData.extConfig['subscribeId6'],
					getApp().globalData.extConfig['subscribeId5'],
					getApp().globalData.extConfig['subscribeId4']
				])
				let existErr = configMess.some(item => item.errorCode)
				if(existErr) {
					let filterRefuse =  configMess.filter(item => item.errorCode !== '10001030') // 用户未拒绝的列表
					let statusOne =  filterRefuse.some(item => item.errorCode === '10001024') // 是否存在总关闭
					let statusTwoList =  filterRefuse.filter(item => item.errorCode === '10001025') // 关闭开关消息的且未拒绝的
					if(statusOne) {
						ks.openSetting()
					} else if(statusTwoList && statusTwoList.length) { // 关闭开关消息的切未拒绝的
						tmplIdsList = statusTwoList.map(item => item.templateId)
						
					} 
				} else {
					tmplIdsList= [
						getApp().globalData.extConfig['subscribeId6'], 
						getApp().globalData.extConfig['subscribeId4'], 
						getApp().globalData.extConfig['subscribeId5']
					]
				}
				if(getApp().globalData.extConfig['subscribeId4'] || getApp().globalData.extConfig['subscribeId5'] || getApp().globalData.extConfig['subscribeId6']){
					let res = await uni.requestSubscribeMessage({
						tmplIds: tmplIdsList
					})

					if((res[0] || {}).errCode === 10001027 || (res[0] || {}).errMsg === 'requestSubscribeMessage:fail repeated request') {
						uni.showToast({
							title: `请去设置开启订阅消息`,
							icon: 'none'
						})

						// 弹窗拉取失败
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_fail'
						})
					}

					if((res[1] || {})[getApp().globalData.extConfig['subscribeId6']] === 'ACCEPT') {
						// 弹窗拉取允许
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_agree'
						})
					} else if ((res[1] || {})[getApp().globalData.extConfig['subscribeId6']] === 'REFUSE') {
						// 弹窗拉取拒绝
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_disagree'
						})
					}

					if((res[1] || {})[getApp().globalData.extConfig['subscribeId5']] === 'ACCEPT') {
						// 弹窗拉取允许
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_agree'
						})
					} else if ((res[1] || {})[getApp().globalData.extConfig['subscribeId5']] === 'REFUSE') {
						// 弹窗拉取拒绝
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_disagree'
						})
					}

					if((res[1] || {})[getApp().globalData.extConfig['subscribeId4']] === 'ACCEPT') {
						// 弹窗拉取允许
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_agree'
						})
					} else if ((res[1] || {})[getApp().globalData.extConfig['subscribeId4']] === 'REFUSE') {
						// 弹窗拉取拒绝
						this.$uma && this.$uma.trackEvent('Ume_Subscribe', {
							name: 'Ume_Subscribe_sign_in_disagree'
						})
					}
				}
				

				this.$refs.zwyPopupSign.close()
            } catch (error) {
                console.log(error)
            }
        },
		// 打开设置
		openSetting() { 
			uni.openSetting({
					success (res) { 
						console.log('res====', res)
					}
				}
			)
		},
        handleJumpMore(type) {
            uni.navigateTo({
				url: `../mayLike/mayLikeTwo?type=${type}`
			})
        },
		toDetail(item) {
			console.log(item)
			if(!item.fakeId && !item.contentInfo.fakeId) return
			this.zwyRouter(`../video/video?fakeId=${item.fakeId || (item.contentInfo || {}).fakeId}&compilationId=${item.compilationId || (item.contentInfo || {}).compilationId}`);
		},
		addInterVal() {
			clearInterval(this.intervalObj)
			this.intervalObj = setInterval(() => {
				this.direction = 'left'
				this.TowerEnd()
			}, 5000)
		},
        // 获取在追列表
        async getNowWatchList() {
            try {
                let res = await this.zwyRequest({
                    url: '/cdp/user_subscribe/compilations'
                })
				this.realList = res
				this.viewGoView = true
				this.nowWatchList = (res || []).slice(0, 3)
            } catch (error) {
                console.log(error)
            }
        },
        // 获取猜你会追
		async getList(type) {
			if (type == 'refresh') {
				this.noMore = 2;
				this.pageNum = 1;
			} else {
				this.noMore = 2;
			}
			this.zwyRequest({
				url: `/cdp/index/compilations/related`
			}).then(res => {
				if (res) {
					let tempList;
					if (type == 'refresh') {
						tempList = res.slice(0, 6);
					} else {
						tempList = this.historyList.concat(res);
					}
					let tempMore = 0;
					this.pageNum++;
					if (res.length == 0) {
						tempMore = 1;
					}
					this.historyList = tempList;
					this.noMore = tempMore;
					this.listLength = tempList.length;
				}
			});
		},
		// 获取首页配置
		async getIndexConfig() {
			try {
				let res = await this.zwyRequest({
					url: '/cdp/section_group',
					method: 'GET',
					data: {
						sectionGroupTypeValue: 4
					}
				})
				this.recommendObj = (res.find(item=> item.styleType === 'STYLE_16') || {})
				this.historyTitle = this.recommendObj.name
				this.historyList = this.recommendObj.contents.slice(0, 6) || []
				// this.recommendObj = (res.find(item=> item.styleType === 'STYLE_15') || {})
				// this.swiperList = this.recommendObj.contents ? this.recommendObj.contents.slice(0, 3) : []
				// // 初始化轮播配置
				// this.TowerSwiper('swiperList')

				// // 本地存储防止2次弹起
				// let status = this.$store.state.viewPopupIndex

				// console.log('status', status)
				// if(!status && this.swiperList.length) {
				// 	setTimeout(() => {
				// 		this.$refs.zwyPopupAll.show('mid')
				// 		this.addInterVal()
				// 		this.$store.state.viewPopupIndex = true
				// 	}, 100)
				// }

				// this.$forceUpdate();
			} catch (error) {
				console.log(error)
			}
		},
		// 获取签到活动状态
		async getSignActiveStatus(type) {
			try {
				let res = await this.zwyRequest({
					url: '/welfare/sign_in',
					method: 'GET'
				})
				let {
					latestRewards,
					continuousSignInDays
				} = res

				this.signListView = latestRewards || []
				this.continuousSignInDays = continuousSignInDays || 0
				
				// 自动签到
				let nowDay = latestRewards.find(item => item.isToday)
				if(!nowDay.isSignIn) {
					this.signStatusChange()
				}
				
				if(type === 'viewSign') {
					this.nowItem = this.signListView.find(item => item.isToday)
					this.handleSign()
				}
			} catch (error) {
				console.log(error)
			}
		},
		// 签到
		async signStatusChange(type) {
			try {
				if(type === 'click') {
					uni.showToast({
						title: `今天已签到`,
						icon: 'none'
					})
					return
				}
				let res = await this.zwyRequest({
					url: '/welfare/sign_in',
					method: 'PUT'
				})

				if(res) {
					this.getSignActiveStatus('viewSign')
				}
				
			} catch (error) {
				console.log(error)
			}
		},
		// 订阅上报
		async addDingMess() {
			try {
				let tmplIdsList = []
				let configMess = await this.checkConfigDingYue([
					getApp().globalData.extConfig['subscribeId6'],
					getApp().globalData.extConfig['subscribeId1'],
					getApp().globalData.extConfig['subscribeId2']
				])
				let templateTypeList = [
					{
						templateId: getApp().globalData.extConfig['subscribeId6'],
						templateType: 3
					},
					{
						templateId: getApp().globalData.extConfig['subscribeId1'],
						templateType: 1
					},
					{
						templateId: getApp().globalData.extConfig['subscribeId2'],
						templateType: 2
					}
				]
				let existErr = configMess.some(item => item.errorCode)
				if(existErr) {
					let filterRefuse =  configMess.filter(item => item.errorCode !== '10001030') // 用户未拒绝的列表
					let statusTwoList =  filterRefuse.filter(item => item.errorCode === '10001026') // 关闭开关消息的且未拒绝的
					if(statusTwoList && statusTwoList.length) { // 关闭开关消息的切未拒绝的
						tmplIdsList = statusTwoList.map(item => {
							return templateTypeList.find(typeData => typeData.templateId === item.templateId)
						})
					} else {
						tmplIdsList = templateTypeList
					}
				} else {
					tmplIdsList= templateTypeList
				}
				if(getApp().globalData.extConfig['subscribeId4'] || getApp().globalData.extConfig['subscribeId5'] || getApp().globalData.extConfig['subscribeId6']){
					
					await this.zwyRequest({
						url: '/mp-api/user_one_time_subscribe/batch',
						method: 'POST',
						data: {
							sourceType: 3,
							sourceId: 0,
							sourceDesc: '',
							templates: tmplIdsList
						}
					})
				}
			} catch (error) {
				console.log(error)
			}
		},
		// 订阅前查询
		async checkConfigDingYue(list) {
			try {
				let temIds = list

				let res = await this.zwyRequest({
					url: '/mp-api/user_one_time_subscribe/subscribe_status',
					method: 'POST',
					data: temIds
				})
	
				return res
			} catch (error) {
				console.log(error)
			}
		}
	},
	onShareAppMessage: function () {
	    var shareJson = {
	      path: '/pages/fx_xjc/fx_xjc',
	      data: {
			page: 'hj_history',
	        sharePosition: '/pages/fx_xjc/fx_xjc',
	        'from': '/position/share/share',
	        sharePage: '/pages/fx_xjc/fx_xjc',
	      }
	    }
		// 达人分享批次
        console.log(getApp().globalData.shareBatchId)
        if(getApp().globalData.shareBatchId) {
            shareJson.channel = 'video'
            shareJson.extra = {
                hashtag_list: ['精彩短剧热播中👈']
            }
        }
	    shareJson.title = '精彩短剧热播中👈';
	    return this.formatShare(shareJson)
	},
	async created() {
		// this.getList('refresh')
		// this.getNowWatchList()
		// this.getIndexConfig()
		// this.getSignActiveStatus()
	}
};
</script>

<style lang="scss" scoped>
.container999 {
	background: #ffffff;
}
.content-view {
	background: #fff;
	width: 550rpx;
	border-radius: 33rpx;
	position: relative;
	.btn-set {
		width: 386rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		font-size: 32rpx;
		border-radius: 80rpx;
		margin: 21rpx 0 45rpx;
		background: #F66E8E;
		border: none;
	}
	.mark-box-set {
		width: 360rpx;
	}
	.img-box-one {
		width: 121rpx;
		height: 121rpx;
		margin-left: -25rpx;
	}
	.img-box-two {
		width: 386rpx;
	}
	.close-btn {
		position: absolute;
		right: 36rpx;
		top: 40rpx;
		width: 28rpx;
		height: 28rpx;
	}
}
.block-box {
    display: flex;
    flex-direction: column;
    padding: 15rpx 25rpx;
    .title {
        margin-left: 5rpx;
        font-size: 36rpx;
        margin-bottom: 20rpx;
        line-height: 50rpx;
        font-weight: 600;
        color: #333333;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .more-icon {
            font-weight: normal;
            font-size: 26rpx;
            line-height: 37rpx;
            color: #999999;
        }
    }
    .content-list {
        display: flex;
        overflow: auto;
		&.style-two {
			flex-wrap: wrap;
			.no-right {
				margin-right: 0;
			}
			.item-box {
				margin-bottom: 21rpx;
			}
		}
        .item-box {
            display: flex;
            flex-direction: column;
            margin-right: 14rpx;
			.img-box-set {
				width: 223rpx;
				height: 315rpx;
				background: #F5F7FB;
				border-radius: 13rpx;
				image {
					display: table-cell;
					width: 70rpx;
					height: 70rpx;
				}
				.btn-set {
					width: 152rpx;
					height: 53rpx;
					border: 1rpx solid #F66E8E;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #F66E8E;
					font-size: 28rpx;
					margin-top: 32rpx;
					border-radius: 27rpx;
				}
			}
            .img-box {
                width: 223rpx;
                height: 315rpx;
                border-radius: 13rpx;
                overflow: hidden;
                image {
                    display: table-cell;
                    width: 223rpx;
                    height: 315rpx;
                }
            }
            .title-box {
                width: 100%;
                color: #333333;
                font-size: 30rpx;
                line-height: 42rpx;
                margin: 11rpx 0 3rpx;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                width: 223rpx;
            }
        }
    }
}
page {
	background-color: white !important;
	border-top: 1rpx solid #f6f6f6;
}
.topBox {
	position: relative;
	.content-position {
		height: 402rpx;
	}
	.bg-box {
		width: 166%;
		height: 418rpx;
		background: linear-gradient(317deg, #5E6888 0%, #303750 100%);
		box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.04);
		border-radius: 0 0 50% 50%;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
	}
	.content-box {
		margin: auto;
		width: 700rpx;
		min-height: 293rpx;
		background: #fff;
		z-index: 994;
		border-radius: 30rpx;
		box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.09);
		position: absolute;
		left: 50%;
		top: 43rpx;
		transform: translateX(-50%);
	}
}
.content-box {
	.top-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 36rpx;
		line-height: 50rpx;
		padding: 10rpx 0 2rpx 32rpx;
		font-weight: 600;
		color: #333333;
		.num-view {
			color: #FF6FA2;
			font-size: 60rpx;
			line-height: 70rpx;
			margin: 0 10rpx;
		}
		.right-box {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			line-height: 40rpx;
			margin-top: 20rpx;
			font-weight: normal;
			.switch-box {
				transform: scale(0.7);
				
			}
		}
	}
	.text-box {
		padding: 0 32rpx;
		font-size: 26rpx;
		color: #999999;
	}
	.watch-sign-box {
		display: flex;
		justify-content: space-between;
		padding: 29rpx 32rpx 0;
		.line-box {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 74rpx;
			height: 108rpx;
			background: #F5F7FB;
			box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.07);
			border-radius: 12rpx;
			&.active {
				background: #F66E8E;
				text {
					color: #fff;
				}
			}
			image {
				width: 65rpx;
			}
			text {
				text-align: center;
				color: #949494;
			}
		}
	}
}

.tower-swiper .tower-item {
	transform: scale(calc(0.5 + var(--index) / 10));
	margin-left: calc(var(--left) * 100upx - 150upx);
	z-index: var(--index);
}
.tower-item.none {
	opacity: 0.6 !important;
}

.tower-swiper .tower-item .swiper-item {
	border-radius: 13rpx;
	overflow: hidden;
	display: flex;
	justify-content: center;
	image {
		width: 345rpx;
		width: 242rpx;
		border-radius: 13rpx;
	}
}

.tower-swiper {
	width: 100%;
	height: 345rpx;
}

.task-popup {
	width: 710rpx;
	height: 140rpx;
	background: #FFFFFF;
	box-shadow: 0rpx 0rpx 18rpx 0rpx rgba(0,0,0,0.09);
	border-radius: 10rpx;
	padding: 0 40rpx 0 36rpx;
	margin: 0 auto 22rpx;
	.image-task-box {
		height: 58rpx;
		width: 58rpx;
		display: table-cell;
	}
	.right-btn {
		width: 188rpx;
		height: 64rpx;
		background: #E5768F;
		border-radius: 32rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		font-size: 30rpx;
	}
}

.opacity-set {
	opacity: 0.8;
}
</style>
